#include "tests.h"

TEST(StackTest, Constructor_Default) {
  s21::stack<int> stack;

  EXPECT_EQ(stack.size(), 0);
}

TEST(StackTest, Constructor_InitializerList_NotEmpty) {
  s21::stack<int> stack = {1, 2, 4};

  EXPECT_EQ(stack.size(), 3);
  EXPECT_EQ(stack.top(), 4);
}

TEST(StackTest, Constructor_InitializerList_Empty) {
  s21::stack<int> stack = {};

  EXPECT_EQ(stack.size(), 0);
}

TEST(StackTest, Constructor_Copy) {
  s21::stack<int> stack = {1, 2, 3};

  s21::stack<int> copy{stack};

  EXPECT_EQ(copy.size(), 3);
  EXPECT_EQ(copy.top(), 3);
}

TEST(StackTest, Constructor_Move) {
  s21::stack<int> stack = {1, 2, 3};
  s21::stack<int> dist{std::move(stack)};

  EXPECT_EQ(stack.size(), 0);
  EXPECT_EQ(dist.size(), 3);
  EXPECT_EQ(dist.top(), 3);
}

TEST(StackTest, Opertator_Copy) {
  s21::stack<int> stack1 = {1, 2, 3};
  s21::stack<int> stack2 = {4, 5, 6, 7};

  stack1 = stack2;

  EXPECT_EQ(stack1.size(), 4);
  EXPECT_EQ(stack2.size(), 4);
  EXPECT_EQ(stack1.top(), stack2.top());
}

TEST(StackTest, Opertator_Move) {
  s21::stack<int> stack1 = {1, 2, 3};
  s21::stack<int> stack2 = {4, 5};

  stack1 = std::move(stack2);

  EXPECT_EQ(stack1.size(), 2);
  EXPECT_EQ(stack2.size(), 0);
}

TEST(StackTest, Top_Const) {
  const s21::stack<int> stack = {4, 5, 6};

  EXPECT_EQ(stack.top(), 6);
}

TEST(StackTest, Empty) {
  s21::stack<int> stack;

  EXPECT_TRUE(stack.empty());
}

TEST(StackTest, Size) {
  s21::stack<int> stack = {4, 5, 6, 7};

  EXPECT_EQ(stack.size(), 4);
}

TEST(StackTest, Push) {
  s21::stack<int> stack = {4, 5, 6, 7};
  const int number = 8;

  stack.push(number);
  stack.push(9);

  EXPECT_EQ(stack.size(), 6);
  EXPECT_EQ(stack.top(), 9);
}

TEST(StackTest, Pop) {
  s21::stack<int> stack = {4, 5, 6, 7};

  stack.pop();
  stack.pop();

  EXPECT_EQ(stack.size(), 2);
  EXPECT_EQ(stack.top(), 5);
}

TEST(StackTest, Clear) {
  s21::stack<int> stack = {1, 2, 3, 4, 5};

  stack.clear();

  EXPECT_TRUE(stack.empty());
}

TEST(StackTest, Swap) {
  s21::stack<int> stack1 = {4, 5, 6, 7};
  s21::stack<int> stack2 = {1, 2, 3};

  stack1.swap(stack2);

  EXPECT_EQ(stack1.size(), 3);
  EXPECT_EQ(stack1.top(), 3);
  EXPECT_EQ(stack2.size(), 4);
  EXPECT_EQ(stack2.top(), 7);
}

TEST(StackTest, InsertManyFront_Empty) {
  s21::stack<int> stack;

  stack.insert_many_front(1, 2, 3);

  EXPECT_EQ(stack.size(), 3);
  EXPECT_EQ(stack.top(), 3);
}

TEST(StackTest, InsertManyFront_NotEmpty) {
  s21::stack<int> stack = {1, 2, 3};

  stack.insert_many_front(4, 5);

  EXPECT_EQ(stack.size(), 5);
  EXPECT_EQ(stack.top(), 5);
}